var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var EventManager = require("AA_EventManager");
var ResKeeper = require("AA_ResKeeper");
var TimeUtils = require("AA_TimeUtils");
var EvenType = require("AA_EvenType");
var PlayerDataManager = require("AA_PlayerDataManager");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;
_decorator.inspector;
var _def_AddPowerByTime = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.timeLabel = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onEnable = function () {
    this.ResetShowTime();
    EventManager.EventMgr.addEventListener(EvenType.EVENT_TYPE.Hall_ResetRich, this.ResetShowTime, this);
  };
  _creator.prototype.onDisable = function () {
    EventManager.EventMgr.rmEventListener(EvenType.EVENT_TYPE.Hall_ResetRich, this.ResetShowTime, this);
  };
  _creator.prototype.ResetShowTime = function () {
    var e = this;
    this.timeLabel.node.stopAllActions();
    this.timeLabel.string = "";
    if (PlayerDataManager.PlayerDataMgr.globalData.power < PlayerDataManager.PlayerDataMgr.globalData.maxPower) {
      var t = new Date().getTime();
      var o = 6e4 * GameGlobalVariable.GameGlobalVariable.addPowerTime;
      var n = t - PlayerDataManager.PlayerDataMgr.globalData.lastAddPowerTime;
      if (n >= o) {
        var i = Math.floor(n / o);
        if (PlayerDataManager.PlayerDataMgr.globalData.power + i > PlayerDataManager.PlayerDataMgr.globalData.maxPower) {
          return void PlayerDataManager.PlayerDataMgr.AddPower(PlayerDataManager.PlayerDataMgr.globalData.maxPower - PlayerDataManager.PlayerDataMgr.globalData.power);
        }
        PlayerDataManager.PlayerDataMgr.AddPower(i);
        n -= i * o;
        PlayerDataManager.PlayerDataMgr.globalData.lastAddPowerTime = t - n;
      }
      n = o - n;
      n = Math.floor(.001 * n);
      this.timeLabel.string = TimeUtils.default.secondsToMinutesSeconds(n);
      this.timeLabel.node.runAction(cc.repeatForever(cc.sequence(cc.delayTime(1), cc.callFunc(function () {
        n--;
        e.timeLabel.string = TimeUtils.default.secondsToMinutesSeconds(n);
        0 == n && e.ResetShowTime();
      }))));
    }
  };
  __decorate([_property(cc.Label)], _creator.prototype, "timeLabel", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_AddPowerByTime;